﻿using System;
using System.Collections.Generic;
using JavaDevToys.Rcl.Entities;
using Microsoft.EntityFrameworkCore;

namespace JavaDevToys.Rcl.Context;

public partial class HisDbContext : DbContext
{
    public HisDbContext()
    {
    }

    public HisDbContext(DbContextOptions<HisDbContext> options)
        : base(options)
    {
    }

    public virtual DbSet<DevtoysCustomcode> DevtoysCustomcodes { get; set; }

    public virtual DbSet<DevtoysCustomcodeGroup> DevtoysCustomcodeGroups { get; set; }

    public virtual DbSet<DevtoysProject> DevtoysProjects { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseSqlServer("Server=10.0.0.220;Database=HISDB;uid=HIS_DICT;pwd=HIS_DICT@123;TrustServerCertificate=true");

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .HasDefaultSchema("HIS_DICT")
            .UseCollation("Chinese_PRC_CI_AS");

        modelBuilder.Entity<DevtoysCustomcode>(entity =>
        {
            entity.HasKey(e => e.DevtoysCustomcodeId).HasName("PK__DEVTOYS___0D411ECDD2066B24");

            entity.ToTable("DEVTOYS_CUSTOMCODE");

            entity.Property(e => e.DevtoysCustomcodeId)
                .HasColumnType("numeric(19, 0)")
                .HasColumnName("DEVTOYS_CUSTOMCODE_ID");
            entity.Property(e => e.CustomcodeCode)
                .HasColumnType("text")
                .HasColumnName("CUSTOMCODE_CODE");
            entity.Property(e => e.CustomcodeDesc)
                .HasColumnType("text")
                .HasColumnName("CUSTOMCODE_DESC");
            entity.Property(e => e.CustomcodeName)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("CUSTOMCODE_NAME");
            entity.Property(e => e.DevtoysCustomcodeGroupId)
                .HasColumnType("numeric(19, 0)")
                .HasColumnName("DEVTOYS_CUSTOMCODE_GROUP_ID");
        });

        modelBuilder.Entity<DevtoysCustomcodeGroup>(entity =>
        {
            entity.HasKey(e => e.DevtoysCustomcodeGroupId).HasName("PK__DEVTOYS___2CABA03CD08BB01F");

            entity.ToTable("DEVTOYS_CUSTOMCODE_GROUP");

            entity.Property(e => e.DevtoysCustomcodeGroupId)
                .HasColumnType("numeric(19, 0)")
                .HasColumnName("DEVTOYS_CUSTOMCODE_GROUP_ID");
            entity.Property(e => e.GroupName)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("GROUP_NAME");
        });

        modelBuilder.Entity<DevtoysProject>(entity =>
        {
            entity.HasKey(e => e.DevtoysProjectId).HasName("PK__DEVTOYS___691790BED98B6FCD");

            entity.ToTable("DEVTOYS_PROJECT");

            entity.Property(e => e.DevtoysProjectId)
                .HasColumnType("numeric(19, 0)")
                .HasColumnName("DEVTOYS_PROJECT_ID");
            entity.Property(e => e.ProjectDatabase)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("PROJECT_DATABASE");
            entity.Property(e => e.ProjectDesc)
                .HasMaxLength(2000)
                .IsUnicode(false)
                .HasColumnName("PROJECT_DESC");
            entity.Property(e => e.ProjectName)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("PROJECT_NAME");
            entity.Property(e => e.ProjectPort)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("PROJECT_PORT");
            entity.Property(e => e.ProjectPwd)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("PROJECT_PWD");
            entity.Property(e => e.ProjectSchemas)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("PROJECT_SCHEMAS");
            entity.Property(e => e.ProjectServer)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("PROJECT_SERVER");
            entity.Property(e => e.ProjectUsername)
                .HasMaxLength(200)
                .IsUnicode(false)
                .HasColumnName("PROJECT_USERNAME");
            entity.Property(e => e.ProjectType)
                .IsUnicode(false)
                .HasColumnName("PROJECT_TYPE");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
